<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xmlns:th='http://www.thymeleaf.org'>

<head>
	<meta charset='UTF-8'/>
	<link rel='stylesheet' type='text/css' href='themes/material/easyui.css'/>
	<link rel='stylesheet' type='text/css' href='themes/icon.css'/>
	<link rel='stylesheet' type='text/css' href='css/style.css'/>
</head>

<body>
	<div id='toolbar' class='top'><ul style='padding-left:5px'><li th:each='btn:${btnlist}'>
		<a href='#' class='easyui-linkbutton' plain='true' onclick='' th:attrappend='onclick=${btn.btnfunc}'>
		<i class='fa fa-' th:attrappend='class=${btn.btnicon}'></i>&nbsp;<span th:text='${btn.btnname}'></span></a></li></ul>
		<span style='float:right;padding-right:20px;padding-top:5px'>
		<a href='#' class='easyui-linkbutton' plain='true' onclick='doSearch()'>
		<span id='showItem'><i class='fa fa-plus-square-o fa-lg'></i>&nbsp;<font size='15'>查询</font></span></a></span>
	</div>
	<div id='searchTerm' style='display:none;'><ul>
		<li><label>用户名</label><input class='easyui-textbox' id='accname'/></li>
		</ul>
		<span style='float:right;padding-right:20px;'>
			<a href='#' class='easyui-linkbutton' iconCls='fa fa-search' plain='true' onclick='getList()'>查询</a>
			<a href='#' class='easyui-linkbutton' iconCls='fa fa-undo' plain='true' onclick='clearCdt()'>重置</a>
		</span>
	</div>
	<div id='common-dialog' class='easyui-dialog' modal='true' closed='true' style='display:none;width:335px;height:390px'>
		<div class='easyui-layout' fit='true'>
			<form id='common-form' class='easyui-form' method='post'>
				<input type='hidden' name='id'/>
				<div region='center' border='false'>
				<div class='centerdiv'>
				<table><tr><td><label>登录帐号：</label>
					<input class="easyui-textbox"  name="acccode" id="ucode" 
						data-options="validType:['usrcode'],required:true"/></td></tr>
					<tr><td><label>用户姓名：</label>
					<input class='easyui-textbox' name='accname' id="accname" data-options='required:true'/></td></tr>
					<tr><td><label>所属代理：</label>
					<select name="orgid"  id="pgrp"></select></td></tr>
					<tr><td><label>用户角色：</label>
					<select name="roleid"  id="prole"></select></td></tr>
					<tr><td><label>联系方式：</label>
					<input class='easyui-textbox' name='accphone' id="accphone" data-options="validType:['mobile'],required:true"/></td></tr>
					<tr><td><label>电子邮箱：</label>
					<input class='easyui-textbox' name='accemail' id="accemail" data-options="required:true,validType:['email']"/></td></tr>
					<tr><td><label>帐号状态：</label>
					<select class="easyui-combobox" name="state" id="state" data-options="prompt:'请选择账号状态',required:true,editable:false">
				    	<option value="0">正常</option><option value="1">禁用</option></select></td></tr>
				</table></div></div>
				<div region='south' border='false' class='southdiv'>
				<a class='easyui-linkbutton' icon='fa fa-check-square-o' href='#' onclick="common_submit(-1,'',0)">保存</a>
				<a class='easyui-linkbutton' icon='fa fa-undo' href='#' onclick='common_reset()'>重置</a>
	</div></form></div></div>
	<table id='common-table'></table>
	<ul id="spgrp"></ul>
	<ul id="sprole"></ul>
	<script type='text/javascript' src='jquery.min.js'></script>
	<script type='text/javascript' src='jquery.easyui.min.js'></script>
	<script type="text/javascript" src="js/validate.js"></script>
	<script type='text/javascript' src='js/util.js'></script>
	<script>
		$(function(){
			$('#common-table').datagrid({
				border:false,
				rownumbers: true,
				fitColumns: true,
				fit:true,
				url: '/d/userlist',
				method: 'post',
				striped : true,
				pagination:true,
				pageSize:25,
				pageList:[25,50],
				toolbar:'#toolbar',
				columns:[[
					{title:'选择',field:'id',checkbox:true},
					{title:'登录号',field:'acccode',align:'center',width:100},
					{title:'用户名',field:'accname',align:'center',width:100},
					{title:'所属代理',field:'orgname',align:'center',width:100},
					{title:'角色名称',field:'rolename',align:'center',width:100},
					{title:'联系方式',field:'accphone',align:'center',width:150},
					{title:'电子邮箱',field:'accemail',align:'center',width:150},
					{title:'创建时间',field:'crttm',align:'center',width:150,formatter:formatDate},
					{title:'帐号状态',field:'state',align:'center',width:100,
						formatter: function(value,row,index){
							if(value == 0)
								return '正常';
							else if(value == 1)
								return '禁用';
							else
								return value;
						}
					},
				]]
			})
			$('#pgrp').combo({
				required:true,
				editable:false,
				prompt:'请选择代理商'
			});
			$('#spgrp').appendTo($('#pgrp').combo('panel'));
			$('#spgrp').tree({
				url : '/d/orgComBox',
				animate:true,
				lines:true,
				onClick:function(node){
					$('#pgrp').combo('setValue', node.id).combo('setText', node.text).combo('hidePanel');
				}
			});
			$('#prole').combo({
				required:true,
				editable:false,
				prompt:'请选择角色'
			});
			$('#sprole').appendTo($('#prole').combo('panel'));
			$('#sprole').tree({
				url : '/d/roleComBox',
				animate:true,
				lines:true,
				onClick:function(node){
					$('#prole').combo('setValue', node.id).combo('setText', node.text).combo('hidePanel');
				}
			});
		});
		function add(){
			$('#ucode').textbox({	disabled:false	});
			common_add('新增','/d/usrsave');
		}
		function edit(){
			$('#ucode').textbox({	disabled:true	});
			common_edit('编辑','/d/usredit');
		}
		function del(){
			common_delete('/d/usrdel',-1,'',0);
		}
		function getList(){
			var params = {'accname':$('#accname').textbox('getValue')};
			$('#common-table').datagrid('load',params);
		}
		function clearCdt(){
			$('#accname').textbox('setValue','');
			getList();
		}
		function clearEdit(){
			$('#accname').textbox('setValue','');
			$('#pgrp').combobox('setValue', "-1");
			$('#prole').combobox('setValue', "-1");
			$('#accphone').textbox('setValue','');
			$('#accemail').textbox('setValue','');
			$('#state').combobox('setValue', "-1");
		}
	</script>
</body>
</html>
